﻿// ---------------------------------------------------------------------------------------------
// <copyright file="RoutingRecordsDS.cs" company="www.swyx-forum.com">
//     (c) Martin Hüser
// </copyright>
// <summary>Defines custom dataset functionality</summary>
// ---------------------------------------------------------------------------------------------
namespace IpPbxImportRR.RoutingRecordsDSTableAdapters
{
    /// <summary>
    /// Routing records table adapter partial definition
    /// </summary>
    public partial class RoutingRecordsTableAdapter
    {
        /// <summary>
        /// currently used routing record table name
        /// </summary>
        private string currentTableName = "RoutingRecords$";

        /// <summary>
        /// set RoutingRecords table name in SQL commands.
        /// </summary>
        /// <param name="name">table name to use in SQL statements</param>
        /// <remarks>dataset for excel sheet uses sheet name as table name, but for importing CSV files, table name 
        /// has to be the file name. This functions allows replacing the name in all SQL statements</remarks>
        public void SetTableName(string name)
        {
            if (this._adapter.SelectCommand == null || string.IsNullOrEmpty(this._adapter.SelectCommand.CommandText))
            {
                this.Adapter.SelectCommand = this._commandCollection[0];
            }

            this._adapter.SelectCommand.CommandText = 
                this._adapter.SelectCommand.CommandText.Replace(this.currentTableName, name);

            this._adapter.InsertCommand.CommandText = 
                this._adapter.InsertCommand.CommandText.Replace(this.currentTableName, name);

            this.currentTableName = name;
        }
    }
}

namespace IpPbxImportRR {
    
    
    public partial class RoutingRecordsDS {
    }
}
